package com.fs.console.yuezi.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fs.common.pojo.CheckRecipes;
import com.fs.common.yzMapper.CheckRecipesMapper;
import com.fs.console.base.enums.CodeEnum;
import com.fs.console.base.vo.JsonResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author ACE
 * @desc 检查后食谱controller
 * @creationTime 2019-08-22 09:01
 * @projectName yuezi-menu
 * @packageName com.fs.console.yuezi.controller
 */
@Slf4j
@Controller
@RequestMapping("/console/checkRecipes/rewrite")
public class CheckRecipesController {
    @Autowired
    private CheckRecipesMapper checkRecipesMapper;

    @ResponseBody
    @RequestMapping("/selectId")
    public JsonResponse selectId(String id){
        try {
            String[] split = id.split(",");
            List<String> ids = new ArrayList<>(Arrays.asList(split));
            QueryWrapper<CheckRecipes> wrapper = new QueryWrapper<>();
            wrapper.in("id",ids);
            List<CheckRecipes> list = checkRecipesMapper.selectList(wrapper);
            return JsonResponse.success(list);
        }catch (Exception e){
            e.printStackTrace();
            log.error(e.getMessage());
            return JsonResponse.error(CodeEnum.EX999);
        }
    }
}
